package com.liuyang.concurrency.chapter4;

public class ThreadJoin3 {
    public static void main(String[] args) throws InterruptedException {
        Thread t1 = new Thread(new CaptureRunnable("m1",1_000));
        Thread t2 = new Thread(new CaptureRunnable("m2",5_000));
        Thread t3 = new Thread(new CaptureRunnable("m3",8_000));
        t1.start();
        t2.start();
        t3.start();

        t1.join();
        t2.join();
        t3.join();

        System.out.println("end capture and end save");
    }

}

class CaptureRunnable implements Runnable{
    private String name;
    private int spendTime;

    public CaptureRunnable(String name, int spendTime) {
        this.name = name;
        this.spendTime = spendTime;
    }

    @Override
    public void run() {
        try {
            Thread.sleep(spendTime);
            System.out.println(name+" complete capture");
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
}